/*************************************************************************
 *
 *  elksip - a multi-platform Sip Phone Server
 *
 *  file: elk_port.h
 *
 *  Copyright 2011-2013 Elksip team.
 *
 ************************************************************************/
#ifndef _ELK_PORT_H_
#define _ELK_PORT_H_

#ifndef WIN32
#include<pthread.h>
#endif

#define sip_free(P) { if (P!=NULL) { free(P); P=NULL;} }
#define SIP_FREE(P) { if (P!=NULL) { free(P); P=NULL;} }
#define ELK_FREE(P) { if (P!=NULL) { free(P); P=NULL;} }
#define ELK_MALLOC(a)  malloc(a)

int elk_thread_create(void *(*start_routine) (void *), void *arg);
#if 0
int elk_mutex_lock(); 
int elk_mutex_unlock(); 
int elk_mutex_init( ) ;
#endif

#ifndef WIN32
typedef struct tdElk_Mutex{
     pthread_mutex_t  mutex;
}Elk_Mutex;
#else
typedef struct tdElk_Mutex{
    int mutex;//TODO
}Elk_Mutex;
#endif

void elk_mutex_lock(Elk_Mutex *mutex);
void elk_mutex_unlock(Elk_Mutex *mutex);

#endif //_ELK_PORT_H_
